import variables from "@/styles/theme.scss";
import defaultSettings from "@/settings";

const { showSettings, fixedHeader } = defaultSettings;

const state = {
  showSettings: showSettings,
  fixedHeader: fixedHeader,
  isStripe: localStorage.getItem("isStripe") === "true" ? true : false // 表格是否显示斑马线，默认值从缓存中取
};

const mutations = {
  CHANGE_SETTING: (state, { key, value }) => {
    if (state.hasOwnProperty(key)) {
      state[key] = value;
    }
  },
  /* 通用更新方法. @param {Object} payload = {key, value} */
  SET: (state, payload) => {
    state[payload.key] = payload.value;
  },
  
  SETSTRIPE: (state, payload) => {
    state.isStripe = payload.value;
  }
};

const actions = {
  changeSetting({ commit }, data) {
    commit("CHANGE_SETTING", data);
  }
};

export default {
  namespaced: true,
  state,
  mutations,
  actions
};
